package model;

import java.util.ArrayList;
import java.util.List;

/**
 * @Create Harlantown
 * @Description
 * @create 2022-12-27 下午 9:47
 */
public class PageTable {
    // 页表链表的链表头
    public static PageTable pageTableHead = new PageTable();
    // 链表中上一块
    private PageTable preTable;
    // 链表中下一块
    private PageTable nextTable;
    // 具体页表
    public List<PageTableEntry> list;

    public PageTable() {
        this.list = new ArrayList<>();
    }

    public void add(PageTableEntry pageTableEntry) {
        this.list.add(pageTableEntry);
    }

    public static void appendTableList(PageTable pageTable){
        PageTable ptr = pageTableHead;
        while (ptr.nextTable != null) {
            ptr = ptr.nextTable;
        }
        ptr.nextTable = pageTable;
        pageTable.preTable = ptr;
    }

    public PageTable getPreTable() {
        return preTable;
    }

    public void setPreTable(PageTable preTable) {
        this.preTable = preTable;
    }

    public PageTable getNextTable() {
        return nextTable;
    }

    public void setNextTable(PageTable nextTable) {
        this.nextTable = nextTable;
    }
}
